package example1;

import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCTest {

    @Test
    public void t1() throws Exception {
        String url = "jdbc:mysql:///yyds.test";
        String user = "root";
        String password = "root";
        String sql = "SELECT ID,name,pass,age,LOGIN_DATE FROM USER";

        Class.forName("com.mysql.cj.jdbc.Driver");
        try (Connection conn = DriverManager.getConnection(url, user, password);
             Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql)) {
            while (rs.next()){
                String id = rs.getString("ID");
                String string = rs.getString(1);
                String string1 = rs.getString(0);
                System.out.println("");
            }

        }
    }

}
